#include "Pacs_MyLineEdit.h"
#include <QIcon>
#include <QMouseEvent>
#include <QHBoxLayout>
Pacs_MyLineEdit::Pacs_MyLineEdit(QWidget *parent)
	: QLineEdit(parent)
{
	m_btnShowCheckPart = new QPushButton;
	m_btnShowCheckPart->setFixedSize(28,28);
	m_btnShowCheckPart->setStyleSheet("QPushButton{border:none;border-image:url(:/Pacs_Client/image/plus.png);}QPushButton:hover{border:none;border-image:url(:/Pacs_Client/image/plus.png);background-color:rgb(204,232,255)}");
	m_listWidgetCheckPart = new QListWidget;
	QHBoxLayout *layout = new QHBoxLayout;
	layout->setContentsMargins(0,0,3,0);
	layout->addWidget(m_btnShowCheckPart);
	layout->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
	m_showPartWidget = new Pacs_ShowCheckPart;
	connect(m_showPartWidget, &Pacs_ShowCheckPart::newString, this, &Pacs_MyLineEdit::setSelectString);
	this->setLayout(layout);
	//connect 
	connect(m_btnShowCheckPart, &QPushButton::clicked, this, &Pacs_MyLineEdit::on_Clicked_ShowPartList);
	m_userCheckPart = DBOperate::GetKernel()->getUserCheckPart();
}

void Pacs_MyLineEdit::mouseMoveEvent(QMouseEvent *e)
{
	QLineEdit::mouseMoveEvent(e);
	this->setToolTip(this->text());
}
void Pacs_MyLineEdit::mousePressEvent(QMouseEvent *e)
{
	if (e->button() == Qt::LeftButton)
	{
		if (m_userCheckPart.length() > 0) 
		{

		}
	}
	QLineEdit::mousePressEvent(e);
}
void Pacs_MyLineEdit::setSelectString(QStringList strList)
{
	QString newStr= "";
	for (int i = 0; i < strList.length(); ++i) 
	{
		if (i == 0) {
			newStr += strList[i];
			continue;
		}
		newStr += ","+strList[i];
	}
	this->setText(newStr);
}

void Pacs_MyLineEdit::on_Clicked_ShowPartList()
{
	m_showPartWidget->onShowWidget();
}

void Pacs_MyLineEdit::InitShowWidget()
{
// 	m_widget = new QWidget;
// 	m_btnOk = new QPushButton;
// 	m_btnCancel = new QPushButton;
	
}


Pacs_MyLineEdit::~Pacs_MyLineEdit()
{

}
